<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>卡拉卡-在线选号平台</title>
		<link href="/css/style.css" rel="stylesheet" type="text/css" />
		<link href="/css/pagination.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="../js/jquery-1.7.min.js"></script>
		<script type="text/javascript" src="../js/jquery.pagination.js"></script>
		<script type="text/javascript" src="../js/jquery.cookie.js"></script>
		<script type="text/javascript" src="../js/logon.js"></script>
		<script language="javascript" type="text/javascript">
			var page = 0; //页面索引初始值
			var pageSize = 48; //每页显示条数初始化，修改显示条数，修改这里即可
			$(function () {
				//initTable(10); //Load事件，初始化表格数据，页面索引为0（第一页）
				//分页，PageCount是总条目数，这是必选参数，其它参数都是可选
				$("#Pagination").pagination($!{model.get("count")}, {
					callback:PageCallback, //PageCallback() 为翻页调用次函数。
					prev_text:"上一页",
					next_text:"下一页",
					items_per_page:pageSize,
					num_edge_entries:2, //两侧首尾分页条目数
					num_display_entries:3, //连续分页主体部分分页条目数
					current_page:page, //当前页索引
				});
				//翻页调用
				function PageCallback(page,jq) {
					initTable(page);
				}
				//请求数据
				function initTable(page) {
					$.ajax({
						type:"POST",
						dataType:"text",
						url:"/phone/page/$!{model.get("carrier")}", //提交到一般处理程序请求数据
						data:{page:page+1,pageSize:pageSize,min:'$!{model.get("min")}',max:'$!{model.get("max")}',start:'$!{model.get("start")}',end:'$!{model.get("end")}',keyword:'$!{model.get("keyword")}'}, //提交两个参数：pageIndex(页面索引)，pageSize(显示条数)
						success:function(data){
						//alert(data);
							$('#list-content').html('');
							$('#list-content').html(data);
						}
					});
				}
			});
			
			function search()
			{
				var min=$("#min").val();
				if(isNaN(min))
				{
					$("#min").val(0);
				}
				
				var max=$("#max").val();
				if(isNaN(max))
				{
					$("#max").val(0);
				}
				
				var start=$("#start").val();
				if(isNaN(start))
				{
					$("#start").val("");
				}
				
				var end=$("#end_").val();
				if(isNaN(end))
				{
					$("#end_").val("");
				}
				$("#searchForm").submit();
			}
			
			//选号码
			function pick()
			{
				var pid = $("#pid").val();
				if(pid && pid>0)
				{
					$.ajax({    
				        type:'post',
				        url:'/sale/check',
				        data:{pid:pid},
				        cache:false,
				        async:false,
				        dataType:'json',
				        success:function(data){
				        	if(data.msg =="true" ){
					            document.getElementById("pid").value=pid;
								$('#searchForm').attr("action", "/package");
								$("#searchForm").target="_self";
								$("#searchForm").submit();
					        }else{
					            alert("号码已被选，再选一个吧！");
					        }
				        },
				        error: function(){  //失败
					        alert('Error loading document');
					    }
				    });
				}
				else
				{
					alert("选个号先");
				}
			}
			
			//选中效果
			var tip;
			function ri(obj,pid)
			{
				//$(this).lastChild.addClass("sel");
				if(tip)
				{
					$(tip).children("td").eq(1).removeClass();
				}
				$(obj).children("td").eq(1).addClass("sel");
				tip=obj;
				$("#pid").val(pid);
				//alert($(obj).children("td").eq(1).text());
			}
			//双击事件
			function dblc(obj,pid)
			{
				ri(obj,pid);
				pick();
			}
			#if($!{model.get("error")}==1)
				alert("号码已被其他用户选了，返回再选一个吧!");
			#end
		</script>
	</head>

	<body>
		#include("header.html")
		<table width="100%" border="0" cellspacing="0" cellpadding="0" id="content">
			<tr>
				<td valign="top" id="left">
					#include("menu_sale.html")
				</td>
				<td valign="top" id="right">
					<div id="list" style="margin-top: 0px;">
						<form id="searchForm" name="searchForm" action="/phone/$!{model.get("carrier")}" method="post">
						<div class="title">
							<span>首页 &gt; $!{model.get("carrierName")} &gt; 选择号码</span>
							<div class="so1" style="padding-top:3px"><input type="button" name="Submit1" value="查询" class="out_btn" onclick="search();" /></div>
							<div class="so">
								<input type="text" name="keyword" class="sou_input" value="$!{model.get("keyword")}"/>
								<input type="hidden" name="carrier" value="$!{model.get("carrier")}"/>
								<input type="hidden" id="pid" name="pid"/>
							</div>
							<div class="so1">
								价格<input type="text" name="min"  class="sou_input1" style="width:60px;" value="$!{model.get("min")}"/> - 
								<input type="text" name="max"  class="sou_input1" style="width:60px;" value="$!{model.get("max")}"/>&nbsp;&nbsp;
								开始
								<input type="text" name="start"  class="sou_input1" style="width:60px;" value="$!{model.get("start")}"/>&nbsp;&nbsp;
								结束
								<input type="text" id="end_" name="end"  class="sou_input1" style="width:60px;" value="$!{model.get("end")}"/>
							</div>
						</div>
						</form>
						<div class="data3">
							<table width="100%" border="0" cellpadding="0" cellspacing="1" style="background:#CCCCCC;">
								<tbody id="list-content">
								</tbody>
							</table>
							<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-top:1px;">
								<tr>
									<td height="50" align="left" style="padding-left:10px;">
										<input type="button" name="Submit" value="下一步" class="out_btn" onclick="pick();" />
									</td>
									<td><div id="Pagination" class="pagination" style="margin:4px 0 0 0"></div></td>
									<td width="80">共$!{model.get("count")}条</td>
								</tr>
							</table>
						</div>
					</div>
				</td>
			</tr>
		</table>
		#include("footer.html")
	</body>
</html>
